//
//  ViewController.swift
//  TCSegement
//
//  Created by 叮叮 on 2021/4/13.
//

import UIKit

class ViewController: UIViewController, TCSegmentDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        TCSegment.titleColor = UIColor.white
        
        let segment = TCSegment(segments: ["1","2","3","4"])
        segment.delegate = self
        view.addSubview(segment)
        
        let top = NSLayoutConstraint(item: segment, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 100)
        let left = NSLayoutConstraint(item: segment, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1, constant: 10)
        let right = NSLayoutConstraint(item: segment, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1, constant: -10)
        let height = NSLayoutConstraint(item: segment, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: 40)
        view.addConstraint(top)
        view.addConstraint(left)
        view.addConstraint(right)
        view.addConstraint(height)
        
    }
    
    func segmentDidSelected(index: Int, segment: UIButton) {
        
    }


}

